package hottargui.config;

import hottargui.framework.*;

public class AlphaEndTurnState implements TarguiState {

	Game gameContext;
	
	public AlphaEndTurnState(Game game)
	{
		this.gameContext = game;
	}
	
	public boolean buy(int count, Position deploy) throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public State getState() {
		return State.endTurn;
	}

	public boolean move(Position from, Position to, int count)
			throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void newGame() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public void rollDie() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

	public PlayerColor turnCard() throws IllegalActionException {
	    GameObjectServer objServer = gameContext.getGameObjectServer();
	    objServer.getGameData().setCurrentColor(objServer.getTurnSequenceStrategy().getNextPlayer());
	    
	    if (objServer.getGameData().getCurrentColor() == PlayerColor.None) {
		gameContext.setState(gameContext.getFactory().getEndRoundState(gameContext));
	    }
	    else {
		gameContext.setState(gameContext.getFactory().getMoveState(gameContext));
	    }
	    return objServer.getGameData().getCurrentColor();
	}

	public PlayerColor getWinner() throws IllegalActionException {
		throw new IllegalActionException(this.getState());
	}

}
